home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0188.ZIP / ITERM.PAS < prev    next >
Pascal/Delphi Source File  |  1986-01-26  |  7KB  |  208 lines

  1. program iterm;
  2. {
  3. Scott Murphy
  4. 77 So. Adams St. #301
  5. Denver, CO 80209
  6. Compuserve 70156,263
  7. }
  8. Const
  9.      VERSION = '1.5';
  10.      SAVE_BUF_SIZE = 2048;             {size of text save buffer}
  11.      BELL_FREQ = 440;                  {frequncy for bell sound}
  12.      BELL_DELAY = 100;                 {duration of bell sound}
  13.      DEFAULT_BAUD = 300;               {Serial port speed at start-up}
  14.  
  15. type
  16.     bigstring        = string[80];    {general purpose}
  17.     cset              = set of 0..127;
  18. var
  19.    SaveText              : 0..1;       {flag for saving text to disk}
  20.    SaveOpen              : boolean;    {flag for open textsave file}
  21.    SaveBuffer            : array[1..SAVE_BUF_SIZE] of char;
  22.    SavePtr               : integer;
  23.    SaveFile              : file of char;
  24.    DiscardSet            : set of 0..127;
  25.    exit,
  26.    xtnd  : boolean;
  27.    a     : byte;
  28.    c,i   : integer;
  29.    PrevLine : string[40];
  30.    CurrLine : string[40];
  31.    LineIndex : integer;
  32.    ch : char;
  33.  
  34. {$C-}
  35. {$I ITRMPORT.INC}
  36. {$I ITRMMISC.INC}
  37. {$I ITRMWIND.INC}
  38. {$I ITRMXFER.INC}
  39. {$I ITRMDIAL.INC}
  40. {$I ITRMSAVE.INC}
  41.  
  42.  
  43. begin
  44.      ClrScr;
  45.      InitWindow(StatWin,1,1,80,2);
  46.      InitWindow(TermWin,1,3,80,25);
  47.      CurrentWin := TermWin;
  48.      UsePermWindow(TermWin);
  49.      status(1,'ITERM ver: ' + VERSION);
  50.      status(2,'Initializing');
  51.      CurrLine := '';
  52.      PrevLine := '';
  53.      LineIndex := 1;
  54.      SaveText := 0;
  55.      SaveOpen := FALSE;
  56.      SavePtr := 1;
  57.      DiscardSet := [];
  58.      InitPhn;
  59.      setup;
  60.      set_up_recv_buffer;
  61.      remove_port;
  62.      setup;
  63.      set_up_recv_buffer;
  64.      exit := false;
  65.      GotoXY(1,1);
  66.      status(2,'Off-Line/Ready');
  67.      while not exit do
  68.      begin
  69.           if keypressed then
  70.           begin
  71.                scan(xtnd, a);
  72.                if xtnd then
  73.                   case a of
  74.                        19   : {alt-R}
  75.                               recv_wcp;
  76.                        45   : {alt-X}
  77.                               begin
  78.                                    OpenTemp(20,18,60,22,1);
  79.                                    writeln('───ITERM───');
  80.                                    write('Do you really want to exit (Y/N)? ');
  81.                                    readln(ch);
  82.                                    if upcase(ch) = 'Y' then
  83.                                       exit := TRUE;
  84.                                    CloseTemp
  85.                               end;
  86.                        67   : {F9}
  87.                               begin
  88.                                    SaveText := 1 - SaveText;
  89.                                    if SaveText = 1 then
  90.                                    begin
  91.                                         Status(3, 'Text save: ON');
  92.                                         if not SaveOpen then
  93.                                            InitSaveFile
  94.                                    end
  95.                                    else
  96.                                       Status(3, 'Text Save: OFF')
  97.                               end;
  98.                        68   : {F10}
  99.                               if SaveOpen then
  100.                               begin
  101.                                    SaveOpen := FALSE;
  102.                                    SaveText := 0;
  103.                                    status(3,'Closing save file');
  104.                                    for i := 1 to SavePtr do
  105.                                        write(SaveFile, SaveBuffer[i]);
  106.                                    close(SaveFile);
  107.                                    Status(3, 'Text Save: OFF')
  108.                               end;
  109.                        31   : {alt-S}
  110.                               send_wcp;
  111.                        32   : {alt-D}
  112.                               auto_dial;
  113.                        35   : {alt-H}
  114.                               begin
  115.                                    writeln('───ITERM───');
  116.                                    status(2,'Disconnecting');
  117.                                    term_ready(FALSE);
  118.                                    delay(500);
  119.                                    term_ready(TRUE);
  120.                                    status(2,'Off-Line/Ready')
  121.                               end;
  122.                        46   : {alt-C}
  123.                               ClrScr;
  124.                        48   : {alt-B}
  125.                               break;
  126.                        25   : {alt-P}
  127.                               NewParms;
  128.                        59   : {F1}
  129.                               if phones[CurPhone].paced then
  130.                                  SendPaced(phones[CurPhone].id + #13)
  131.                               else
  132.                                  StrSend(phones[CurPhone].id + #13);
  133.                        60   : {F2}
  134.                               if phones[CurPhone].paced then
  135.                                  SendPaced(phones[CurPhone].pw + #13)
  136.                               else
  137.                                  StrSend(phones[CurPhone].pw + #13);
  138.                        61   : {F3}
  139.                               SendPaced(PrevLine);
  140.                        77   : {Cursor Right}
  141.                               begin
  142.                                  if LineIndex <= length(PrevLine) then
  143.                                     send(ord(PrevLine[LineIndex]));
  144.                                  LineIndex := LineIndex + 1
  145.                               end;
  146.                       72   : {Cursor up}
  147.                              PushPage;
  148.                       80   : {Cursor Down}
  149.                              PopPage;
  150.                       65   : {F7}
  151.                              SendAscii;
  152.                   end {case}
  153.                else if a = 13 then
  154.                begin
  155.                     PrevLine := CurrLine;
  156.                     Currline := '';
  157.                     LineIndex := 1;
  158.                     send(a)
  159.                end
  160.                else
  161.                begin
  162.                    CurrLine := CurrLine + chr(a);
  163.                    send(a)
  164.                end
  165.           end; {if KeyPressed}
  166.           c := cgetc(0);
  167.           if not (c in DiscardSet) then
  168.           case c of
  169.               -1 : begin
  170.                    end; {no action}
  171.                9 : {tab}
  172.                    begin
  173.                         for c := WhereX to (WhereX div 8 + 1)*8 do
  174.                             write(' ');
  175.                         c := 9
  176.                    end;
  177.                7 : {bell}
  178.                     begin
  179.                          sound(BELL_FREQ);
  180.                          delay(BELL_DELAY);
  181.                          NoSound
  182.                     end;
  183.                12 : {form-feed}
  184.                     ClrScr;
  185.               else  write(chr(c and $7F));
  186.           end; {case}
  187.           if (c <> -1) and (SaveText = 1) and (not (c in DiscardSet)) then
  188.                DiskBuffer(chr(c));
  189.      end; {while not exit}
  190.      remove_port;
  191.      if cflag then
  192.      begin
  193.           status(3,'Updating ITERM.PHN');
  194.           rewrite(phfile);
  195.           for c := 1 to MAXPHONES do
  196.               write(phfile, phones[c]);
  197.           close(phfile)
  198.      end;
  199.      if SaveOpen then
  200.      begin
  201.           status(3,'Closing save file');
  202.           for i := 1 to SavePtr do
  203.               write(SaveFile, SaveBuffer[i]);
  204.           close(SaveFile)
  205.      end;
  206.      ClrScr;
  207. end.
  208.